<?php
header("Content-type:text/html;charset=utf-8");
$link = mysqli_connect('localhost','root','123456','xiaomi');
$bool = $_GET['bool'];
$cb = $_GET['callback'];
if($bool=='1'||$bool=='0'){
    $cb = $_GET["callback"];
    $username = $_GET['username'];
    $password = $_GET['password'];
}

if($bool=='1'){
    $sql = "SELECT * FROM `user` WHERE `userName`=$username AND `passWord`=$password";
    $res = mysqli_query($link,$sql);

    $arr = mysqli_fetch_all($res,MYSQL_ASSOC);

    $num = count($arr);//54
  
    echo "$cb($num)";
    // echo $num;
}
else if($bool=='0'){
    $sql = "INSERT INTO `user` VALUES (null,$username,$password)";
    $res = mysqli_query($link,$sql);
    // echo $res;
    echo "$cb($res)";
}

?>